<template>
	<view>
	<uni-card title="发送卡">
			<view class="box">
				<view class="box_t">
					<span class='mozu_t'>规格型号</span>
					<view class="vc">
						<uni-easyinput  type="number" v-model="waibu.fasongka" placeholder=""></uni-easyinput>
					</view>
				</view>
				<view class="box_t">
					<span class='mozu_t'>数量(张)</span>
					<view class="vc">
						<uni-easyinput @blur="shandleBlur"  v-model="waibu.fasongkashu" placeholder=""></uni-easyinput>
					
					</view>
	
				</view>
	
			</view>
			<view class="box">
	
				<view class="box_t">
					<span class='mozu_t'>单价
					</span>
					<view class="vc">
						<uni-easyinput disabled=true v-model="waibu.fasongkadanjia" placeholder="模组的长度"></uni-easyinput>
					</view>
	
				</view>
	
				<view class="box_t">
	              <span class='mozu_t'>金额
					</span>
					<view class="vc">
						<uni-easyinput disabled=true v-model="fasongkazong" placeholder="模组的高度"></uni-easyinput>
	
					</view>
	
				</view>
			</view>
			
	
		</uni-card>
	  <uni-card title="处理器">
	  		<view class="box">
	  			<view class="box_t">
	  				<span class='mozu_t'>规格型号</span>
	  				<view class="vc">
	  					<uni-easyinput  type="number" v-model="waibu.chiliqixing" placeholder=""></uni-easyinput>
	  				</view>
	  			</view>
	  			<view class="box_t">
	  				<span class='mozu_t'>数量(张)</span>
	  				<view class="vc">
	  					<uni-easyinput @blur="shandleBlurch"  v-model="waibu.chuliqishu" placeholder=""></uni-easyinput>
	  				
	  				</view>
	  
	  			</view>
	  
	  		</view>
	  		<view class="box">
	  
	  			<view class="box_t">
	  				<span class='mozu_t'>单价
	  				</span>
	  				<view class="vc">
	  					<uni-easyinput disabled=true v-model="waibu.chiliqijiage" placeholder="模组的长度"></uni-easyinput>
	  				</view>
	  
	  			</view>
	  
	  			<view class="box_t">
	                <span class='mozu_t'>金额
	  				</span>
	  				<view class="vc">
	  					<uni-easyinput disabled=true v-model="chuliqizong" placeholder="模组的高度"></uni-easyinput>
	  
	  				</view>
	  
	  			</view>
	  		</view>
	  		
	  
	  	</uni-card>
		
		
		<uni-card title="配电柜">
				<view class="box">
					<view class="box_t">
						<span class='mozu_t'>规格型号</span>
						<view class="vc">
							<uni-easyinput  disabled=true  type="number" v-model="waibu.pdidianguiName" placeholder=""></uni-easyinput>
						</view>
					</view>
					<view class="box_t">
						<span class='mozu_t'>数量(台)</span>
						<view class="vc">
							<uni-easyinput @blur="shandleBlupeidn"  v-model="waibu.pdidianguishu" placeholder=""></uni-easyinput>
						
						</view>
		
					</view>
		
				</view>
				<view class="box">
		
					<view class="box_t">
						<span class='mozu_t'>单价
						</span>
						<view class="vc">
							<uni-easyinput @blur="shandleBlupeidanjia" v-model="waibu.peidianguidanjia" placeholder="模组的长度"></uni-easyinput>
						</view>
		
					</view>
		
					<view class="box_t">
		              <span class='mozu_t'>金额
						</span>
						<view class="vc">
							<uni-easyinput disabled=true v-model="peidanguizong" placeholder="模组的高度"></uni-easyinput>
		
						</view>
		
					</view>
				</view>
				
		
			</uni-card>
			<uni-card title="电脑">
					<view class="box">
						<view class="box_t">
							<span class='mozu_t'>规格型号</span>
							<view class="vc">
								<uni-easyinput disabled=true  type="number" v-model="waibu.diannaoname" placeholder=""></uni-easyinput>
							</view>
						</view>
						<view class="box_t">
							<span class='mozu_t'>数量(台)</span>
							<view class="vc">
								<uni-easyinput @blur="shandleBlupeidnsd"  v-model="waibu.diannaoshu" placeholder=""></uni-easyinput>
							
							</view>
			
						</view>
			
					</view>
					<view class="box">
			
						<view class="box_t">
							<span class='mozu_t'>单价
							</span>
							<view class="vc">
								<uni-easyinput @blur="shandleBlupeidnssd" v-model="waibu.dianaodanjia" placeholder="模组的长度"></uni-easyinput>
							</view>
			
						</view>
			
						<view class="box_t">
			              <span class='mozu_t'>金额
							</span>
							<view class="vc">
								<uni-easyinput disabled=true v-model="diannaozong" placeholder="模组的高度"></uni-easyinput>
			
							</view>
			
						</view>
					</view>
					
			
				</uni-card>
				<uni-card title="空调">
						<view class="box">
							<view class="box_t">
								<span class='mozu_t'>规格型号</span>
								<view class="vc">
									<uni-easyinput disabled=true  type="number" v-model="waibu.kongtiaoname" placeholder=""></uni-easyinput>
								</view>
							</view>
							<view class="box_t">
								<span class='mozu_t'>数量(台)</span>
								<view class="vc">
									<uni-easyinput @blur="shandlesaaaasdsd"  v-model="waibu.kongtiaoshu" placeholder=""></uni-easyinput>
								
								</view>
				
							</view>
				
						</view>
						<view class="box">
				
							<view class="box_t">
								<span class='mozu_t'>单价
								</span>
								<view class="vc">
									<uni-easyinput @blur="shandleBkongkk" v-model="waibu.kongtiaojiage" placeholder="模组的长度"></uni-easyinput>
								</view>
				
							</view>
				
							<view class="box_t">
				              <span class='mozu_t'>金额
								</span>
								<view class="vc">
									<uni-easyinput disabled=true v-model="kongtiaozong" placeholder="模组的高度"></uni-easyinput>
				
								</view>
				
							</view>
						</view>
						
				
					</uni-card>
					<uni-card title="框架">
							<view class="box">
								<view class="box_t">
									<span class='mozu_t'>规格型号</span>
									<view class="vc">
										<uni-easyinput disabled=true  type="number" v-model="waibu.kaungjianame" placeholder=""></uni-easyinput>
									</view>
								</view>
								<view class="box_t">
									<span class='mozu_t'>数量(平方)</span>
									<view class="vc">
										<uni-easyinput disabled=true @blur="shandlesaaaad"  v-model="waibu.kuangjiashu" placeholder=""></uni-easyinput>
									
									</view>
					
								</view>
					
							</view>
							<view class="box">
					
								<view class="box_t">
									<span class='mozu_t'>单价
									</span>
									<view class="vc">
										<uni-easyinput @blur="shandleBkong" v-model="waibu.kaungjiajiage" placeholder="模组的长度"></uni-easyinput>
									</view>
					
								</view>
					
								<view class="box_t">
					              <span class='mozu_t'>金额
									</span>
									<view class="vc">
										<uni-easyinput disabled=true v-model="kaungjiazzong" placeholder="模组的高度"></uni-easyinput>
					
									</view>
					
								</view>
							</view>
							
					
						</uni-card>
						<uni-card title="安装">
								<view class="box">
									<view class="box_t">
										<span class='mozu_t'>规格型号</span>
										<view class="vc">
											<uni-easyinput disabled=true  type="number" v-model="waibu.anzhuangname" placeholder=""></uni-easyinput>
										</view>
									</view>
									<view class="box_t">
										<span class='mozu_t'>数量(平方)</span>
										<view class="vc">
											<uni-easyinput disabled=true @blur="shandlssesaaaad"  v-model="waibu.anzhuangshu" placeholder=""></uni-easyinput>
										
										</view>
						
									</view>
						
								</view>
								<view class="box">
						
									<view class="box_t">
										<span class='mozu_t'>单价
										</span>
										<view class="vc">
											<uni-easyinput @blur="shandleBkonn" v-model="waibu.anzhaungjiage" placeholder="模组的长度"></uni-easyinput>
										</view>
						
									</view>
						
									<view class="box_t">
						              <span class='mozu_t'>金额
										</span>
										<view class="vc">
											<uni-easyinput disabled=true v-model="anzhuangzong" placeholder="模组的高度"></uni-easyinput>
						
										</view>
						
									</view>
								</view>
								
						
							</uni-card>
							
							<view class="sdsds">
									
									</view>
							<button @click="goSearch" type="primary">生成excel</button>
							<view class="sds">
								
							</view>
	</view>
</template>

<script>
	
	// mozupin:'',//模组的品牌
	// mozupxinghao:'',// 模组型号
	// mozuchang:0,//模组的长度
	// mozugao:0,//模组的高度，
	// mozujiage:0,//模组的价格
	// xiangsuchang:0,//长像素点
	// xiangsugao:0,//高像素点
	// kongzhikaa:null,//控制卡品牌
	// kongzhikaxinx:"无",//控制卡型号
	// kongzhikadanjia:0,//控制卡单价
	// fasongka:'无',//发送卡
	// fasongkadanjia:0,//发送卡单价
	// tongxunA:0,//通讯A
	// tongxunB:0,//通讯B
	// daizai:12,//带载
	// dainjianju:0,//点间距
	// dianyuanpin:"无",//电源品牌
	// dianyuanpinmodel:"无",//电源型号
	// dianyuanjiage:0,//电源价格
	// dianyuangonglv:0,//电源功率
	// chiliqipin:"无",//处理器品牌
	// chiliqixing:'无',//处理器型号
	// chiliqijiage:0,//处理器价格
	// box:"无",//箱体
	// boxbian:0,//箱体边厚
	// boxjiage:0,//箱体价格
	// zuzhaungxiang:"无",//组装箱体
	// zuzhaungjiage:0,//组装箱体价格
	// kaungjianame:"无",//框架名字
	// kaungjiazhuanjiao:0,//框架转角数量
	// zhuanjiaojiage:0,//转角价格
	// kaungjiabian:0,//框架边厚
	// kaungjiadanjai:0,//框架价格
	// kaungjiadanjiage:0,//框架但面积价格
	// bieitaoname:"无",//背条名字
	// beitiaojiage:0,//背条价格
	// wangixnName:'无',//网线名字
	// wangxianjiage:0,//网线价格
	// shuilv:0,//税率
	// zongchang:0,//总长
	// zongkuan:0,//总宽
	
	export default {
		data() {
			return {
				waibu:{
					fasongka:'无',//发送卡规格型号
					fasongkadanjia:0,//发送卡单价
					fasongkashu:0,//发送卡数量
					fasongkazong:0,//发送卡总价
					chiliqixing:'无',//处理器型号
					chiliqijiage:0,//处理器价格
					chuliqishu:0,//处理器数量
					chuliqizong:0,//处理器总价
					pdidianguiName:'无',//配电柜名字
					pdidianguishu:1,//配电柜数量
					peidianguidanjia:0,//配电柜单价、
					peidanguizong:0,//配电柜总价
					diannaoname:'无',//电脑名字
					dianaodanjia:0,//电脑单价
					diannaoshu:1,//电脑数量
					diannaozong:0,//电脑总价
					kongtiaoname:'无',//空调名字
					kongtiaojiage:0,//空调价格
					kongtiaoshu:2,//空调数量
					kongtiaozong:0,//空调总价
					kaungjianame:'无',//框架名字
					kaungjiajiage:0,//框架单面积价格
					kuangjiashu:0,//框架数量
					kaungjiazzong:0,//框架总价
					anzhuangname:'无',//安装的名字
					anzhaungjiage:0,//安装的价格
					anzhuangshu:0,//安装的数量
					anzhuangzong:0,//安装的总价
				}
			};
		},	methods:{
			
			// 获取被电柜
		async	Getpeidiangui(){
				const {data} = await uni.$http.post('/meng/Getpeidiangui',{model:'18kw'})
				
				if(data.data[0].status==1){
					// 配单轨名字
					this.waibu.pdidianguiName=data.data[0].model
					// 配电柜单价
					this.waibu.peidianguidanjia=data.data[0].price
				}
				
			},
			// 获取空调
		async	Getkongrtiao(){
			const {data} = await uni.$http.post('/meng/Getkongrtiao',{model:'2.5p'})
			
			if(data.data[0].status==1){
				this.waibu.kongtiaojiage=data.data[0].price
				this.waibu.kongtiaoname=data.data[0].model
			}
		},
			// 获取电脑
			async Getdiannao(){
				const {data} = await uni.$http.post('/meng/Getdiannao',{model:'常规'})
				
				if(data.data[0].status==1){
					this.waibu.diannaoname=data.data[0].model
					this.waibu.dianaodanjia=data.data[0].price
				}
				
			},
			// 获取安装
			async Getanzhuang(){
				const {data} = await uni.$http.post('/meng/Getanzhuang',{model:'安装调试'})
				
				// anzhuangname:'',//安装的名字
				// anzhaungjiage=:0,//安装的价格
				if(data.data[0].status==1){
					this.waibu.anzhuangname=data.data[0].model
					this.waibu.anzhaungjiage=data.data[0].price
				}
			},
				// 转移数据
				
				zhuanyi(){
					this.waibu.fasongka=this.wai.fasongka
					this.waibu.fasongkadanjia=this.wai.fasongkadanjia
					this.waibu.chiliqixing=this.wai.chiliqixing
				    this.waibu.chiliqijiage=this.wai.chiliqijiage
					this.waibu.kaungjiajiage=this.wai.kaungjiadanjiage
					this.waibu.anzhuangshu=this.cheng.chengpinmian
					this.waibu.kaungjianame=this.wai.kaungjianame
					
					
					if(this.waibu.kaungjianame=="无"){
						this.waibu.kuangjiashu=0
					}else{
						this.waibu.kuangjiashu=this.cheng.chengpinmian
					}
					
					// 匹配型号中的数量
					const regex =  /[（(](.*?)[）)]/g;
					
					let mach=regex.exec(this.waibu.chiliqixing)
					// 如果匹配成功
				if(mach){
					const pattern = /\d+/g;
				  let naa=	pattern.exec(mach[1])
				  console.log(naa[0]);
				  
				  this.waibu.chuliqishu=naa[0]
				}
					
				},
				shandleBkonn(e){
					this.waibu.anzhaungjiage=e.detail.value
				},
				shandlesaaaasdsd(e){
					this.waibu.kongtiaoshu=e.detail.value
				},
				shandleBkongkk(e){
					this.waibu.kongtiaojiage=e.detail.value
				},
				shandlesaaaad(e){
					this.waibu.kongtiaoshu=e.detail.value
				},
				shandleBkong(e){
					this.waibu.kongtiaojiage=e.detail.value
				},
				
				shandleBlupeidnssd(e){
					this.waibu.dianaodanjia=e.detail.value
				},
				shandleBlupeidnsd(e){
					this.waibu.diannaoshu=e.detail.value
				},
				shandleBlupeidanjia(e){
					this.waibu.peidianguidanjia=e.detail.value
				},
				shandleBlur(e){
					this.waibu.fasongkashu=e.detail.value
				},
				shandleBlurch(e){
					this.waibu.chuliqishu=e.detail.value
				},
				shandleBlupeidn(e){
					this.waibu.pdidianguishu=e.detail.value
				},
			async	goSearch(){
					this.waibu.fasongkazong=this.fasongkazong
					this.waibu.chuliqizong=this.chuliqizong
					this.waibu.peidanguizong=this.peidanguizong
					this.waibu.diannaozong=this.diannaozong
					this.waibu.kongtiaozong=this.kongtiaozong
					this.waibu.kaungjiazzong=this.kaungjiazzong
					this.waibu.anzhuangzong=this.anzhuangzong
				
					this.$store.commit('user/updateonewaibu',this.waibu)


                 
				const data = await uni.$http.post('/meng/gerisd',{user:this.userinfo,yusuan:this.wai,wai:this.cheng,bei:this.bei,waibu:this.waibu})
			
				
				if(data.data.code==200){
					uni.downloadFile({
					  url: 'https://www.dahuiled.cn:3004/myFile.xlsx',
					  filePath:wx.env.USER_DATA_PATH+'/报价单.xlsx',
					  success: (res) => {  
						  console.log(res);
						
						   
						   uni.openDocument({
						     filePath: res.filePath,
						      showMenu: true,
						        success: function() {
						       },
						    fail: function(error) {
						       console.log('打开文档失败：' + error.errMsg)
						                 }
						       })
						   
					  //  uni.getFileSystemManager().saveFile({
					  //     tempFilePath: res.filePath,
					  //     success: (res) => {
					  //       // 保存成功，打开文件
							
					  //     },
					  //     fail: (err) => {
					  //       console.error(err);
					  //     },
					  //   });
					  },
					  fail: (err) => {
					    console.error(err);
					  },
					});
				}
		
  


				}
			},
		computed: {
			userinfo(){
				return this.$store.state.user.userinfo
			},
		    wai () {
		     return this.$store.state.user.oneData
		    },
			
			// 备用预算
			bei(){
				
				 return  this.$store.state.user.bei
			},
			// 屏内预算
			cheng(){
				return this.$store.state.user.wai},
			// 发送卡总价
			fasongkazong(){
				return (this.waibu.fasongkashu*this.waibu.fasongkadanjia).toFixed(2)
			},
			// 处理器总价
			chuliqizong(){
			
				return (this.waibu.chiliqijiage*this.waibu.chuliqishu).toFixed(2)
			},
			// 配电柜总价
			peidanguizong(){
				
				
				return (this.waibu.pdidianguishu*this.waibu.peidianguidanjia).toFixed(2)
			},
			// 电脑总价
			diannaozong(){
				// diannaoname:'',//电脑名字
				// dianaodanjia:0,//电脑单价
				return (this.waibu.dianaodanjia*this.waibu.diannaoshu).toFixed(2)
			},
			// 空调总价
			kongtiaozong(){
				// kongtiaojiage:0,//空调价格
				// kongtiaoshu:2,//空调数量
				return (this.waibu.kongtiaojiage*this.waibu.kongtiaoshu).toFixed(2)
			},
			// 框架总价
			kaungjiazzong(){
				return (this.waibu.kaungjiajiage  *this.waibu.kuangjiashu).toFixed(2)
			},
			// 安装价格
			anzhuangzong(){
				// anzhaungjiage:0,//安装的价格
				// anzhuangshu:0,//安装的数量
				return (this.waibu.anzhaungjiage*this.waibu.anzhuangshu).toFixed(2)
			}
			
			},
			
			created() {
				
			this.zhuanyi()
			this.Getpeidiangui()
			this.Getdiannao()
			this.Getkongrtiao()
			this.Getanzhuang()
			},
		
	}
</script>

<style lang="scss">
.uni-easyinput__content-input{color: #000;}
.sdsds {
		height: 30px;
		margin-bottom: 20px;
	}
	.sds{height: 30px;
	}
	.uni-card__header-content-title{font-size: 18px !important;
	color: #029d94 !important;}
	button{background-color: #029d94 !important;}
</style>
